﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using orz.mouxianyu.Models;
using orz.mouxianyu.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using orz.mouxianyu.Extensions.ToolClass;

namespace orz.mouxianyu.Controllers
{
    /// <summary>
    /// 登录验证controller
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    [Authorize]
    public class LoginController : ControllerBase
    {
        private ILoginService _ILoginService;
        public LoginController(ILoginService LoginService)
        {
            this._ILoginService = LoginService;//注入service业务层
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="body"></param>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        [Route("Login")]

        public IActionResult Login([FromBody]LoginDTO body)
        {
            var re = _ILoginService.Login(body);
            var ar = new ApiOkResponse(re);
            return Ok(ar);
        }
    }
}
